home *** CD-ROM | disk | FTP | other *** search
/ Super PC 33 / Super PC 33 (Shareware).iso / spc / sonido / timidity / source / dumb_ctl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-03  |  3.9 KB  |  165 lines

  1. /* 
  2.  
  3.     TiMidity -- Experimental MIDI to WAVE converter
  4.     Copyright (C) 1995 Tuukka Toivonen <titoivon@snakemail.hut.fi>
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 2 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.     dumb_ctl.c
  21.    
  22.     */
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <stdarg.h>
  27.  
  28. #include "config.h"
  29. #include "common.h"
  30. #include "output.h"
  31. #include "controls.h"
  32.  
  33. static void ctl_refresh(void);
  34. static void ctl_total_time(int tt);
  35. static void ctl_master_volume(int mv);
  36. static void ctl_file_name(char *name);
  37. static void ctl_current_time(int ct);
  38. static void ctl_note(int v);
  39. static void ctl_program(int ch, int val);
  40. static void ctl_volume(int channel, int val);
  41. static void ctl_expression(int channel, int val);
  42. static void ctl_panning(int channel, int val);
  43. static void ctl_sustain(int channel, int val);
  44. static void ctl_pitch_bend(int channel, int val);
  45. static void ctl_reset(void);
  46. static int ctl_open(int using_stdin, int using_stdout);
  47. static void ctl_close(void);
  48. static int ctl_read(int32 *valp);
  49. static int cmsg(int type, int verbosity_level, char *fmt, ...);
  50.  
  51. /**********************************/
  52. /* export the interface functions */
  53.  
  54. #define ctl dumb_control_mode
  55.  
  56. ControlMode ctl= 
  57. {
  58.   "dumb interface", 'd',
  59.   1,0,0,
  60.   ctl_open, ctl_close, ctl_read, cmsg,
  61.   ctl_refresh, ctl_reset, ctl_file_name, ctl_total_time, ctl_current_time, 
  62.   ctl_note, 
  63.   ctl_master_volume, ctl_program, ctl_volume, 
  64.   ctl_expression, ctl_panning, ctl_sustain, ctl_pitch_bend
  65. };
  66.  
  67. static FILE *infp=stdin, *outfp=stdout; /* infp isn't actually used yet */
  68.  
  69. static int ctl_open(int using_stdin, int using_stdout)
  70. {
  71.   if (using_stdin && using_stdout)
  72.     infp=outfp=stderr;
  73.   else if (using_stdout)
  74.     outfp=stderr;
  75.   else if (using_stdin)
  76.     infp=stdout;
  77.  
  78.   ctl.opened=1;
  79.   return 0;
  80. }
  81.  
  82. static void ctl_close(void)
  83.   fflush(outfp);
  84.   ctl.opened=0;
  85. }
  86.  
  87. static int ctl_read(int32 *valp)
  88. {
  89.   return RC_NONE;
  90. }
  91.  
  92. static int cmsg(int type, int verbosity_level, char *fmt, ...)
  93. {
  94.   va_list ap;
  95.   if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
  96.       ctl.verbosity<verbosity_level)
  97.     return 0;
  98.   va_start(ap, fmt);
  99.   if (!ctl.opened)
  100.     {
  101.       vfprintf(stderr, fmt, ap);
  102.       fprintf(stderr, "\n");
  103.     }
  104.   else
  105.     {
  106.       vfprintf(outfp, fmt, ap);
  107.       fprintf(outfp, "\n");
  108.     }
  109.   va_end(ap);
  110.   return 0;
  111. }
  112.  
  113. static void ctl_refresh(void) { }
  114.  
  115. static void ctl_total_time(int tt)
  116. {
  117.   int mins, secs;
  118.   if (ctl.trace_playing)
  119.     {
  120.       secs=tt/play_mode->rate;
  121.       mins=secs/60;
  122.       secs-=mins*60;
  123.       fprintf(outfp, "Total playing time: %3d min %02d s\n", mins, secs);
  124.     }
  125. }
  126.  
  127. static void ctl_master_volume(int mv) {}
  128.  
  129. static void ctl_file_name(char *name)
  130. {
  131.   if (ctl.verbosity>=0 || ctl.trace_playing)
  132.     fprintf(outfp, "Playing %s\n", name);
  133. }
  134.  
  135. static void ctl_current_time(int ct)
  136. {
  137.   int mins, secs;
  138.   if (ctl.trace_playing)
  139.     {
  140.       secs=ct/play_mode->rate;
  141.       mins=secs/60;
  142.       secs-=mins*60;
  143.       fprintf(outfp, "\r%3d:%02d", mins, secs);
  144.       fflush(outfp);
  145.     }
  146. }
  147.  
  148. static void ctl_note(int v) {}
  149.  
  150. static void ctl_program(int ch, int val) {}
  151.  
  152. static void ctl_volume(int channel, int val) {}
  153.  
  154. static void ctl_expression(int channel, int val) {}
  155.  
  156. static void ctl_panning(int channel, int val) {}
  157.  
  158. static void ctl_sustain(int channel, int val) {}
  159.  
  160. static void ctl_pitch_bend(int channel, int val) {}
  161.  
  162. static void ctl_reset(void) {}
  163.  
  164.